import os
import sys

script_path = os.path.abspath(__file__)
script_dir = os.path.dirname(script_path)
sys.path.append(script_dir)
from typing import List, Literal, Type
import pygame
from amount import Damage, Life, MSpeed, KSpeed, Sunshine


# 僵尸
class Zombie(pygame.sprite.Sprite):

    sign = "Zombie-sign"

    def __init__(
        self,
        BVolume: Life,
        MSpeed: MSpeed,
        KSpeed: KSpeed,
        Damage: Damage,
        KillTarget: Type,
    ) -> None:
        super().__init__()
        self.BVolume = BVolume
        """僵尸血量"""
        self.MSpeed = MSpeed
        """僵尸移动速度"""
        self.KSpeed = KSpeed
        """僵尸攻击速度"""
        self.Damage = Damage
        """僵尸攻击力"""
        self.KillTarget = KillTarget
        """僵尸攻击目标"""
        self.status: Literal[1, 2, 3] = 1
        """僵尸状态
        1:移动
        2:吃
        3:死亡
        """

    def __sub__(self, other):
        """减少血量"""
        if isinstance(other, Damage):
            self.APower.value -= other.value
        elif isinstance(other, KSpeed):
            self.KSpeed.value -= other.value
        elif isinstance(other, MSpeed):
            self.MSpeed.value -= other.value
        elif isinstance(other, Life):
            self.BVolume.value -= other.value
        else:
            raise TypeError("不支持的减法类型:T:%s" % type(other))
